#! /bin/sh

#set -x

# input and output data
input1=data.su
output1=taup.su
output2=invtaup.su
output3=diff.su

# input parameters:
pmin=-0.0006		# minimum moveout in ms/m
pmax=0.0006             # maximum moveout in ms/m
dx=20                   # horizontal sampling interval (m)
npoints=71              # number of points in rho filter for inverse tau-p
fmin=3			# minimum frequency of interest
np=100

f2=`bc -l<<END
	(1000*($pmin))
END`

dp=`bc -l<<END
	1000*($pmax-($pmin))/($np-1)
END`
echo "dp=$dp pmin=$pmin"
surange < $input1

#*********************************
# 
# Plot parameters:
nbpi=72
#*********************************

# plot input data
suxwigb < $input1 label1="Time (s)" \
	nbpi=$nbpi label2="Trace Number" title="Input data" &

#Compute and plot forward slant stack
sutaup < $input1 option=2 dx=$dx fmin=$fmin \
        pmin=$pmin pmax=$pmax npoints=$npoints  > $output1
echo "maximum amplitude of slant stacked data"
sumax < $output1
suxwigb < $output1 label1="Intercept time (sec)" \
        perc=99.9 nbpi=$nbpi label2="Slope (ms/km)" \
	f2=$f2 d2=$dp title="Forward transform" &

# Compute and plot inverse slant stack with time domain rho filter
sutaup < $output1 option=4 dx=$dx fmin=$fmin \
        rho_F=1 pmin=$pmin pmax=$pmax npoints=$npoints > $output2

echo "maximum amplitude inverse slant stacked data"
sumax < $output2
echo "plotting inverse data with time rho filter."
suxwigb < $output2 label1="Time (s)" \
	nbpi=$nbpi label2="Trace Number" \
	title="Inverse with time rho" &

# compute and plot difference between input and inverse transform
scale=67 # this is the ratio of the absolute max values on input and
         # inverse tau-p transformed data

sugain < $output2 scale=$scale > junk1
suop2 $input1 junk1  op=diff > $output3
echo "maximum amplitude of difference"
sumax < $output3
echo "plotting difference between scaled inverse with time rho and input data"
suxwigb < $output3 label1="Time (s)" \
	nbpi=$nbpi label2="Trace Number" \
	title="Difference with inverse time rho" &
exit 0
